/*
package cn.lhl.service.impl;

import cn.lhl.mp.entity.Lhl_sys_user;
import cn.lhl.mp.service.impl.Lhl_sys_permissionServiceImpl;
import cn.lhl.mp.service.impl.Lhl_sys_userServiceImpl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.authority.AuthorityUtils;
import org.springframework.security.core.userdetails.User;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.stereotype.Service;

@Service("userDetailsService")
public class UserServiceImpl implements UserDetailsService {


    @Autowired
    private Lhl_sys_userServiceImpl lhl_sys_userService;

    @Autowired
    private Lhl_sys_permissionServiceImpl lhl_sys_permissionService;

    @Override
    public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
        //UserLogin userDetails =null;
        //1查user用户
        LambdaQueryWrapper<Lhl_sys_user> queryWrapper = Wrappers.lambdaQuery();
        queryWrapper.eq(Lhl_sys_user::getUsername,username);
        Lhl_sys_user one = lhl_sys_userService.getOne(queryWrapper);

        if(null == one){
            throw new UsernameNotFoundException("用户名或密码错误!");
        }
        //2查用户的权限  (先查用户的role 再查role的权限)

       //lhl_sys_permissionService.list(Wrappers.lambdaQuery().eq())

        //3设置权限
        return new User("","", AuthorityUtils.commaSeparatedStringToAuthorityList("root"));
    }
}
*/
